<template>
	<view class="message">
		<view class="type">
			<view class="typeItem flex alignCenter" v-for="(item,index) in messageArr" :key="index" @click="infoClick(item)">
				<view class="itemIcon">
					<image :src="item.icon" mode="widthFix"></image>
				</view>
				<text class="font16">{{item.title}}</text>
				<text class="num font10" v-if="item.noReadNum>>0">{{item.noReadNum>99?`99+`:item.noReadNum}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		messAllUnreadNum
	} from "@/api/mine.js"
	export default {
		data() {
			return {
				messageArr: [{
					title: '系统消息',
					noReadNum: 0,
					icon: '/static/image/tabbar/info2.png'
				}]
			};
		},
		onShow() {
			this.getAllUnreadMsgNum()
		},
		methods: {
			// 获取各类消息的未读数量
			getAllUnreadMsgNum() {
				messAllUnreadNum().then((res) => {
					if (res.code == 100000) {
						this.messageArr[0].noReadNum = res.data.systemMessageUnReadTotal
					}
				})
			},
			infoClick(item) {
				uni.navigateTo({
					url: '/pages/message/systemInfo/systemInfo'
				})
				return
			}
		}
	}
</script>

<style lang="scss" scoped>
	.message {
		padding: 30rpx;
		box-sizing: border-box;

		.type {
			.itemIcon {
				flex-shrink: 0;
				width: 100rpx;
				height: 100rpx;
				border-radius: 10rpx;
				margin: 0 20rpx 0 0;
				background: #f1f1f1;
			}

			image {
				width: 60rpx;
				height: 60rpx;
				display: block;
				margin: 20rpx auto;
			}
		}

		.typeItem {
			margin: 0 0 30rpx 0;

			.num {
				// display: inline-block;
				width: 40rpx;
				height: 40rpx;
				text-align: center;
				line-height: 40rpx;
				border-radius: 50%;
				background: $reddot;
				color: #fff;
				margin: 0 0 0 10rpx;

			}
		}
	}
</style>